package com.cz.background.service.common;


import com.cz.background.dto.common.login.LoginResultDTO;
import com.cz.background.entity.common.SysUser;
import com.cz.background.mapper.common.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {

    @Autowired
    private SysUserMapper sysUserMapper;

    public LoginResultDTO checkUserPassword(String username, String password) {
        LoginResultDTO loginResultDTO = null;

        SysUser user = sysUserMapper.findByNameAndPassword(username, password);
        if(user != null) {
            loginResultDTO = new LoginResultDTO();
            loginResultDTO.setUserId(user.getId());
            loginResultDTO.setName(username);
        }
        return loginResultDTO;
    }
}
